package com.qf.boot.service.consumer;

import com.qf.boot.service.api.SiteService;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;

@EnableAutoConfiguration
public class LoadBalanceDubboConsumer {
    //consistenthash 111321
    //roundrobin
    @Reference(version = "default",loadbalance = "roundrobin")
    private SiteService siteService;

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(LoadBalanceDubboConsumer.class);
        SiteService siteService= context.getBean(SiteService.class);
        for (int i = 0; i < 12; i++) {
            String name = siteService.getName("qf-" + i % 6);
            System.out.println(name);
        }
//        for (int i = 0; i <10 ; i++) {
//            String name = siteService.getName("q-loadbalance");
//            System.out.println(name);
//        }
    }

}
